package com.zzty.serviceimpl;

import com.zzty.dao.CompetionDao;
import com.zzty.dao.QuestionDao;
import com.zzty.daoimpl.CompetionDaoImpl;
import com.zzty.daoimpl.QuestionDaoImpl;
import com.zzty.entity.SelfExam;
import com.zzty.service.ComService;

import java.util.List;

public class ComServiceImpl implements ComService {
    QuestionDao cd = new QuestionDaoImpl();
    CompetionDao ct = new CompetionDaoImpl();

    public boolean insert(String content,Integer classId,String date) throws Exception {
        boolean result=false;
        String questionId=String.valueOf(cd.insertContent(content));
        if(questionId!=null){
            result=ct.insertQuestionId(questionId,classId,date);
        }
        return result;
    }


    public String getContentByDate(String date) {
        String questionId=ct.getQuestionIdByDate(date);
        String content=null;
        if(questionId!=null) {
            content = cd.getContentById(Integer.valueOf(questionId));
        }
        return content==null?null:content;
    }
    public List getSelfExamToTable(){
        List<SelfExam> selfExams=null;
        if(ct.getSelfExamToTable()==null){
            return null;
        }else{
            selfExams=ct.getSelfExamToTable();
        }
        return selfExams;
    }
    public boolean checkDate(String date){
        boolean result=ct.checkDate(date);
        return result;
    }


}